package com.fqgj.sentry.policy.engine.domain;

import com.fqgj.sentry.policy.engine.domain.enums.OperationTypeEnum;
import com.fqgj.sentry.policy.engine.domain.enums.VariableTypeEnum;

import java.io.Serializable;

/**
 * Created by kennykong on 2017/7/18.
 */
public class Variable implements Serializable {

    /**
     * id
     */
    private Long id;

    /**
     * 字段名（唯一）
     */
    private String name;

    /**
     * 字段 名称
     */
    private String displayName;

    /**
     * 变量类型（整型|小数|日期|字符串）
     */
    private VariableTypeEnum varType;

    /**
     * 运算类型（值类型|脚本类型）
     */
    private OperationTypeEnum opType;
    /**
     * 脚本内容
     */
    private Script script;

    /**
     * 值
     */
    private Object value;

    /**
     * 是否必须
     */
    private Boolean required = true;

    public Boolean getRequired() {
        return required;
    }

    public Variable setRequired(Boolean required) {
        this.required = required;
        return this;
    }

    public String getDisplayName() {
        return displayName;
    }

    public Variable setDisplayName(String displayName) {
        this.displayName = displayName;
        return this;
    }

    public Variable() {
    }

    public Variable(Long id, String name, VariableTypeEnum varType) {
        this.id = id;
        this.name = name;
        this.varType = varType;
    }


    public Variable(Long id, String name, VariableTypeEnum varType, OperationTypeEnum opType) {
        this.id = id;
        this.name = name;
        this.varType = varType;
        this.opType = opType;
    }

    public Variable(Long id, String name, VariableTypeEnum varType, OperationTypeEnum opType, Object value) {
        this.id = id;
        this.name = name;
        this.varType = varType;
        this.opType = opType;
        this.value = value;
    }

    public Variable(String name, Object value) {
        this.name = name;
        this.value = value;
    }

    public Long getId() {
        return id;
    }

    public Variable setId(Long id) {
        this.id = id;
        return this;
    }

    public String getName() {
        return name;
    }

    public Variable setName(String name) {
        this.name = name;
        return this;
    }

    public VariableTypeEnum getVarType() {
        return varType;
    }

    public Variable setVarType(VariableTypeEnum varType) {
        this.varType = varType;
        return this;
    }

    public Object getValue() {

        return value;
    }

    public Variable setValue(Object value) {
        this.value = value;
        return this;
    }

    public OperationTypeEnum getOpType() {
        return opType;
    }

    public Variable setOpType(OperationTypeEnum opType) {
        this.opType = opType;
        return this;
    }

    public Script getScript() {
        return script;
    }

    public Variable setScript(Script script) {
        this.script = script;
        return this;
    }
}
